package com.egg.ylt.presenter.impl;

import android.content.Intent;

import com.egg.ylt.Utils.API;
import com.egg.ylt.Utils.Constants;
import com.egg.ylt.activity.ACT_MultiBigPhotos;
import com.egg.ylt.pojo.CurrentBabyInfoEntity;
import com.egg.ylt.pojo.UserPhotoListEntity;
import com.egg.ylt.view.IPhotoBrowserView;
import com.lzy.imagepicker.ImagePicker;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.mvp.impl.BasePresenter;
import com.yonyou.framework.library.net.ReqCallBack;
import com.yonyou.framework.library.net.RequestManager;

import java.util.HashMap;
import java.util.List;

/**
 * Created By Dlx
 * on 2019/3/3
 */
public class PhotoBrowserPresenter extends BasePresenter<IPhotoBrowserView> {

    public void getUserPhotoList(String itemType, String date, int pageSize, final int pageNum) {
        HashMap<String, String> parms = new HashMap<>();
        parms.put("token", Constants.TOKEN);
        parms.put("companyId", Constants.COMPANYID);
        parms.put("babyId", Constants.BABYID);
        parms.put("type", itemType);
        parms.put("name", date);
        parms.put("pageSize", pageSize + "");
        parms.put("pageNum", pageNum + "");
        RequestManager.getInstance().requestGetByAsyn(API.GET_BABY_PHOTO_LIST, parms, new ReqCallBack<UserPhotoListEntity>() {

            @Override
            public void onReqSuccess(UserPhotoListEntity result) {
                if (pageNum == 1) {
                    mView.onUserPhotoListSuccess(result);
                } else {
                    mView.onLoadMorePhotosSuccess(result);
                }
            }

            @Override
            public void onFailure(String result) {
                if (pageNum == 1) {
                    mView.onUserPhotoListFailed(result);
                } else {
                    mView.onLoadMorePhotosFailed(result);
                }
                mView.showToast(result);
            }

            @Override
            public void onReqFailed(ErrorBean error) {
                mView.showToast(error.getMsg());

            }
        });
    }

    public void jumpToMultiPics(int position){
        mContext.startActivity(new Intent(mContext, ACT_MultiBigPhotos.class)
                .putExtra(ImagePicker.EXTRA_SELECTED_IMAGE_POSITION, position)
                .putExtra(Constants.ENTER_TYPE, ACT_MultiBigPhotos.GROWTH_STAMP_ENTERTYPE));
    }
}
